/*
 * Lop nay dung de convert theo dung dinh dang
 */

package phan.connection;

/**
 *
 * @author bailleurs services
 */
public class convert {
    public convert(){

    }
    // convert date de base de donnée => date française JJ-MM-AAAA
    public String convertDate(String dateSQL){
        String dateNormal="";
        if (dateSQL.length()==10) {
            String Year=dateSQL.substring(0,4);
            System.out.print("test year "+ Year);
            String Month=dateSQL.substring(5,7);
            System.out.print("test Month "+ Month);
            String day=dateSQL.substring(8,10);
            System.out.print("test day "+ day);
            Month=convertDateFrancais(Month);
            dateNormal=day+" "+Month+" "+Year;
        }
        else dateNormal=dateSQL;
        return dateNormal;
    }
    // DateDeFin
    public String GetdateSQLDateDeFin(String dateSQLDateDeBut){
        String GetdateSQLDateDeFin="";
        if (dateSQLDateDeBut.length()==10) {
            String Year=dateSQLDateDeBut.substring(0,4);
             System.out.print(" year Year de fin"+ Year);
            int anne=Integer.parseInt(Year)+1;
            Year=Integer.toString(anne);
            System.out.print("test year "+ anne);
            String Month=dateSQLDateDeBut.substring(5,7);
            System.out.print("test Month " + Month);
            String day=dateSQLDateDeBut.substring(8,10);
            System.out.print("test day " + day);

            GetdateSQLDateDeFin=Year+'-'+Month+'-'+day;
             System.out.print("GetdateSQLDateDeFin la "+ GetdateSQLDateDeFin);
        }
        else GetdateSQLDateDeFin=dateSQLDateDeBut;
        return GetdateSQLDateDeFin;
    }
    public String ddmmyyyy(String yyyymmdd){
        String defin="";

            String Year=yyyymmdd.substring(0,4);
             System.out.print(" year Year de fin"+ Year);



            String Month=yyyymmdd.substring(5,7);
            System.out.print("test Month " + Month);
            String day=yyyymmdd.substring(8,10);
            System.out.print("test day " + day);

            defin=Month+" "+day+" "+Year+yyyymmdd.substring(10, yyyymmdd.length());
             System.out.print("GetdateSQLDateDeFin la "+ defin);

        return defin;
    }
    public String convertDateFrancais(String Month){

        if (Month.length()==2) {
            if(Month.equals("01")){
            Month="Janvier";
            }
            if(Month.equals("02")){
            Month="Février";
            }
            if(Month.equals("03")){
            Month="March";
            }
            if(Month.equals("04")){
            Month="Avril";
            }
            if(Month.equals("05")){
            Month="Mai";
            }
              if(Month.equals("06")){
            Month="Juin";
            }
               if(Month.equals("07")){
            Month="Juillet";
            }
              if(Month.equals("08")){
            Month="aout";
            }
             if(Month.equals("09")){
            Month="septembre";
            }
              if(Month.equals("10")){
            Month="septembre";
            }
              if(Month.equals("11")){
            Month="octorbre";
            }
              if(Month.equals("12")){
            Month="decembre";
            }


        }
        return Month;
    }
    public String hostname(){
        return "192.168.0.12";
    }
     public String addmin(){
        return "dungbt84@gmail.com";
    }
}

